package hash_table;

/**
 * @author 老顾
 * @title: HashMap01
 * @projectName java-restudy
 * @description 不完美哈希
 * @email: 1437594522@qq.com
 * @date 2022/11/7 9:24
 */
public class HashMap01<K,V> implements Map<K,V>{

    private final Object[] tab = new Object[8];

    @Override
    public void put(K key, V value) {
        int index = key.hashCode() & (tab.length - 1);
        tab[index] = value;
    }

    @Override
    public V get(K key) {
        int index =  key.hashCode() & (tab.length - 1);
        return (V) tab[index];
    }
}
